<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>编辑审批表单</title>
	<#include "/common/resource.ftl">
	<script type="text/javascript">
		$(function () {
			<#if (params.taskId)?? || (params.instanceId)??>
				$.ajaxRequest({
					url: '${params.contextPath}/web/workflowStep/getNextStepUsers',
					data: {workflowDefineId: "${params.workflowDefineId!}",stepNum: "${params.stepNum!}"},
					success: function (data) {
						if (!data.success) {
							$.message(data.message);
							return;
						}

						var list = data.data || [], options = "";
						for (var i = 0; i < list.length; i ++) {
						    var item = list[i];
						    $('[name="stepName"]').val(item.stepName);
						    var str = '<option value="{userId}">{userName}</option>';
                            options += str.format(item);
                        }
						$('[name="assigneeId"]').append(options);
						if (list.length <= 0) {
						    $('[name="stepName"]').val("该节点为最后节点");
                            $('[name="assigneeId"]').html('<option value="-100">--该节点为最后节点--</option>');
                        }
					}
				});
			</#if>

            $(".ajax-form2").unbind().submit(function () {
                try {
                    var form = $(this);
                    if (!form.valid()) {
                        $.message("验证不通过，无法提交表单");
                        return false;
                    }

                    form.formSubmit({
                        callBack:function (data) {
                            <#if (params.mobile)??>
                                history.go(-2);
                            </#if>
                        }
                    });
                } catch (e) {
                    console.log("表单提交错误：" + e);
                }
                return false;
            });
		});
	</script>
    <style>
        .layui-input-block{margin-left: 120px;}
        .layui-form-label{width: 90px;}
        input[readonly]{background:#eee;}
    </style>
</head>
<body>
	<div class="ui-form">
		<form class="layui-form ajax-form2" action="${params.contextPath}/web/workflowTask/approvalTask" method="post">
			<input type="hidden" name="taskId" value="${params.taskId!}" />
			<input type="hidden" name="instanceId" value="${params.instanceId!}" />
			<input type="hidden" name="isSubmit" value="${params.sbm!}" />
			<div class="layui-form-item">
                <label class="layui-form-label">下个节点名称</label>
                <div class="layui-input-block">
                    <input type="text" name="stepName" value="" readonly class="layui-input"/>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">选择处理人<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <select name="assigneeId" class="layui-input {required:true}">
                        <option value="">--请选择下个节点处理人--</option>
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">审批时间<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <input type="text" value="${.now?string('yyyy-MM-dd HH:mm')}" readonly class="layui-input {required:true}"/>
                </div>
            </div>
            <#if !((params.sbm)??)>
                <div class="layui-form-item">
                    <label class="layui-form-label">审批意见</label>
                    <div class="layui-input-block">
                        <textarea name="remark" placeholder="请输入审批意见" class="layui-textarea" maxlength="500"></textarea>
                    </div>
                </div>
            </#if>

			<div class="layui-form-item">
				<div class="layui-input-block">
                    <input type="submit" value="确定" class="layui-btn"/>
				</div>
			</div>
		</form>
	</div>
</body>

</html>
